
%***********************************************************************
% C.-Y. Cynthia Lin, 21 March 2014
%-----------------------------------------------------------------------
% The code provided is from the following paper:
%
% Lin, C.-Y. Cynthia.  (2013).  Strategic decision-making with information 
% and extraction externalities:  A structural model of the multi-stage 
% investment timing game in offshore petroleum production.  Review of 
% Economics and Statistics, 95 (5): 1601-1621.
%
% If the code is helpful to you in writing your own code, I would appreciate
% it if you would cite the above paper in your work and acknowledge me 
% for help with the code.  Thank you!
% ------------------------------------------------------------------------
%
% This code estimates the structural econometric model in the following 
% paper:
%
% Lin, C.-Y. Cynthia.  (2013).  Strategic decision-making with information 
% and extraction externalities:  A structural model of the multi-stage 
% investment timing game in offshore petroleum production.  Review of 
% Economics and Statistics, 95 (5): 1601-1621.
%
% 9 parameters are estimated (i.e., profit fxn is linear and there are
% no interaction terms), including coefficient on drilling cost
% in exploration profit function
%
% The main program is run_struc_model.m.
%
%
% STATE VARIABLES
% ---------------
% The state variables are:
%	tot_e_t = total number who explored before lease-yr t
%	tot_d_t = total number who developed before lease-yr t
%	bid_bin_t = discretized avg high bid (avged over the 2 tracts)
%	ce_bin_t = discretized real drilling cost 
%	oilp_bin_t = discretized real oil price
%
% DATA
% ----
% The variables in the panel data input file (created by the
% idl program make_panel.pro) are:
%	mkt_i 
%	t		= yr since lease sale
% 	state variables:
%		tot_e_t = total number who explored before lease-yr t
%		tot_d_t = total number who developed before lease-yr t
%		bid_bin_t = discretized avg high bid (avged over the 2 tracts)
%		ce_bin_t = discretized real drilling cost 
%		oilp_bin_t = discretized real oil price
%       tot_not_e_t = total number who have not explored before lease-yr t 
%       tot_e_not_d_t = total number who are explored at t (ie, by t+1)
%           but have not developed before lease-yr t 
%       n_e_t 		= number who explore from t to (t+1)
%	n_not_e_t 	= number of unexplored who do not explore 
%				from t to (t+1) 
%       n_d_t 		= number who develop from t to (t+1)
%       n_e_not_d_t 	= number who are explored at t (ie, by t+1)
%				but undeveloped before t who 
%				do not develop from t to (t+1)
%       n_e_and_d_t 	= number who both explore & develop from t to (t+1)
%
% The variables we will use from the profit data input file 
% (created by the idl program make_panel.pro) are:
%	gross_profits = (1/inv_royalty_rate) * revenue - cost
%			   for those tracts that develop
%
%
% PARAMETERS
% ----------
% The parameters to be estimated are:
%     sigma_mu
%     sigma_eps
%     ce_factor
%     gamma_tote
%     gamma_totd
%     gamma_bid_bin
%     gamma_cd_bin  (assume ce_bin = cd_bin)
%     gamma_oilp_bin
%     gamma_constant
%
%
%
% MOMENT CONDITIONS
% -----------------
% The moment function for each market-time observation j is: 
%    f(data_j,params) = ...
%      [ ge(tuple_j, params) - ge_emp_j(tuple_j) 
%	 gd(tuple_j, params) - gd_emp_j(tuple_j) 
%	omega_j * ( ge(tuple_j, params) - ge_emp_j(tuple_j) )
%	omega_j * ( gd(tuple_j, params) - gd_emp_j(tuple_j) )  ]
%
%
% The population moment conditions are given by:
%     E[f(data_j,params)]=0 
%
% The sample moment conditions are given by:
%    (1/n sum_j{f(data_j,params)})=0 
% and amount to:
%    sample_mom_conds = 
%    (1/n sum_j{f(data_j,params)})=
%      1/n *
%       [ sum_s{tot_not_e_tuple(s) * (ge(s) - ge_emp(s))} 
%         sum_s{tot_e_not_d_tuple(s) * (gd(s) - gd_emp(s))} 
%         etc     ]
% where s indexes the tuples reached in the data
%
% The weighted moment conditions is (1 X 1)
%    (sample_mom_conds)' weight_matrix^(-1) (sample_mom_conds]) 
%
%
%***********************************************************************

